package org.languageguide.readings;

import java.sql.Connection;
import java.sql.PreparedStatement;

import org.languageguide.storage.DBConnector;

public class FileManager {
	
	public static void addFile(String  readingId, String fileName, String path){
		String sql = "INSERT INTO File (Id, Name, Path) Values (?, ?, ?)";
		DBConnector connector = DBConnector.getInstance();
		Connection connection = connector.getConnection();
		PreparedStatement ps = null;
		try{
			ps = connection.prepareStatement(sql);
			ps.setString(1, readingId);
			
			ps.setString(2, fileName);
			ps.setString(3, path);
			ps.executeUpdate();
			/*ResultSet rs = ps.getGeneratedKeys();
			if (rs.next()) {
				Integer id = rs.getInt(1); 
				//ps.close();
				//return id;
			} 
			else {
			    System.out.println("There are no generated keys.");
			}*/
		}
		catch (Exception e){
				
		}
		
	}
	
	
}
